<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Models\Message;
use App\Transformers\MessageTransformer;

class MessagesController extends Controller
{
    public function index()
    {
    	return $this->response->collection(Message::all(), new MessageTransformer());
    }


    public function show(Message $message)
    {
    	return $this->response->item($message, new MessageTransformer());
    }

    public function store(Request $request, Message $message)
    {
    	$message->fill($request->all());
    	$message->save();

    	return $this->response->item($message, new MessageTransformer());
    }


    public function update(Request $request, Message $message)
    {
    	$message->fill($request->all());
    	$message->update();

    	return $this->response->item($message, new MessageTransformer());
    }


    public function destroy(Message $message)
    {
    	$message->delete();

    	return $this->response->noContent();
    }
}
